﻿Public Class IstBordroBasamak
	Inherits ProcessReport

	Dim bordro, aralik As Input

	Public Overrides Sub GenericEvent(ByVal e As ProcessEventArgs)
		Select Case e.EventType
			Case EventType.Initialize
				Text = "Basamak Dağılım Raporu"
				InitialHelp = "Bordro tipini ve tarih aralığını girin."
				bordro = AddCombo("bordro", "Bordro tipi", "D|D1|D2|E|H|H1|J|J1|K|M|Tümü", "", "", "Bordro tipini girmek zorundasınız.")
				aralik = AddDateRange("Tarih", "nl", "", "", "Başlangıç tarihini girmek zorundasınız.", "Bitiş tarihini girmek zorundasınız.")
				LandScape = True
			Case EventType.ValidateForm
				If aralik(2).IsEmpty Then aralik(2).Set(aralik(1).Get)
				e.Result = True
			Case EventType.ReportDetail
				For Each Item In "D|D1|D2|E|H|H1|J|J1|K|M".Split("|")
					If bordro = "Tümü" OrElse bordro = Item Then
						Report.PrintReportInfo("BASAMAK DAĞILIM RAPORU", "BORDRO TİPİ: " & Item)
						Rs = Istatistik.BordroBasamakDagilim(Remote, Item, aralik(1).Get, aralik(2).Get)
						Report.SetColumns("Tarih;1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16;17;18;19;20;Toplam", "4;3;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;3", "d;n;n;n;n;n;n;n;n;n;n;n;n;n;n;n;n;n;n;n;n;n", "--")
						Dim Tarih As Date = Input("Tarih1")
						Do Until Tarih > Input("Tarih2")
							Dim Rsb As Recordset = Prim.BasamakOku(Remote, "SSY", Tarih)
							Dim C(21) As Integer
							For i As Integer = 1 To 20
								C(i) = IsNull(Rs.Sum("adet", "bordrotar = '" & Tarih & "' and pek >=" & (Rsb("basamak" & Trim(i)) - 2) & " and pek <" & (Rsb("basamak" & Trim(i + 1)) - 2)), 0)
							Next
							C(21) = IsNull(Rs.Sum("adet", "bordrotar = '" & Tarih & "'"), 0)
							Report.Print(Tarih, C(1), C(2), C(3), C(4), C(5), C(6), C(7), C(8), C(9), C(10), C(11), C(12), C(13), C(14), C(15), C(16), C(17), C(18), C(19), C(20), C(21))
							Tarih = Tarih.AddMonths(1)
						Loop
						Report.EndPage()
					End If
				Next
		End Select
	End Sub

End Class
